package com.java.design.observer.java_build_in;




import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

/**
 * java内置订阅者 从java 1.9开始就不支持了*
 *
 * @author Tony
 */
public class WeatherDataJava extends Observable {

    private float temp;

    private float humidity;

    private float pressure;

    public WeatherDataJava(){
    }

    public void measurementsChanged(){
        setChanged();
        notifyObservers();  //通过拉的方式进行处理
    }

    public void setMeasurements(float temp,float humidity,float pressure){
        this.temp  =temp;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    public float getTemp() {
        return temp;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
